<?php 
include 'secure/core.php';
if(!$admin->isAdminLoggedIn()){ 
header('Location: login.php');
}
$id = mysql_real_escape_string($_GET['id']);
$sql = "SELECT * FROM `payment_requests` WHERE `id` = '$id'";         
$res = $ado->exec($sql);
$row_array = mysql_fetch_assoc($res);
$userid = $row_array['userid'];
$date = $row_array['request_date'];
$amount = $row_array['amount'];
$username = $users->getUsername($userid); 
$paypal = $row_array['payment_email'];
$sql1 = "SELECT * FROM `users` WHERE `id` = '$userid'";         
$res1 = $ado->exec($sql1);
$row_array1 = mysql_fetch_assoc($res1);
$email = $row_array1['email'];
$sql = "UPDATE `payment_requests` SET `request_status`= 'completed' WHERE `id` = '$id'"; 
if(mysql_query($sql)) {
$users->sendPaymentComplete($email, $username, $amount, $date, $paypal);
header( 'Location: pending_payments.php?msg=1' ) ;
} else {
header( 'Location: pending_payments.php?msg=2' ) ;
}
?>